Skip to content

Conversation

@trask
Copy link
Member

@trask trask commented Oct 9, 2025

This PR

  • Adds OpenTelemetryConsumerInterceptor and OpenTelemetryProducerInterceptor which accept a KafkaTelemetry instance
  • Deprecates TracingConsumerInterceptor and TracingProducerInterceptor

Went with new class names since we want to get away from "Tracing*" anyways.

Fixes #6291

Supersedes #14870

Copilot AI and others added 22 commits October 3, 2025 00:56
…wards compatibility, move KafkaTelemetrySupplier

Co-authored-by: trask <[email protected]>
…src/main/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/TracingConsumerInterceptor.java
…src/main/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/TracingProducerInterceptor.java
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.


@Test
void badConfig() {
Assumptions.assumeFalse(Boolean.getBoolean("testLatestDeps"));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to not be needed (anymore)

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask marked this pull request as ready for review October 11, 2025 02:29
@trask trask requested a review from a team as a code owner October 11, 2025 02:29
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class KafkaConsumerTelemetry {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make this and other internal classes final?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary if they're truly internal (as opposed to experimental) but also don't mind marking them final if you prefer, in which case I'll update the coding style guidelines: https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/docs/style-guide.md#final-keyword-usage (I'm still planning to bring the changes from that repo over to this repo at some point...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with leaving them as non-final. We aren't super consistent with it. We have a bunch of internal classes that are final and some that are not. If I had to guess I'd say we probably have more final internal classes than non-final.

Map<String, Object> props = super.producerProps();
props.put(
ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingProducerInterceptor.class.getName());
props.putAll(kafkaTelemetry().producerInterceptorConfigProperties());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the new way could fail when kafka properties are configured in a propeties file (idk, whether this is a thing at all) or when there is api built on top of kafka that lets you only set the class name.

Copy link
Member Author

@trask trask Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's modeled after OpenTelemetryMetricsReporter which I think would also have this same problem

includeTestsMatching("*DeprecatedInterceptorsTest")
}
include("**/InterceptorsSuppressReceiveSpansTest.*", "**/WrapperSuppressReceiveSpansTest.*")
forkEvery = 1 // to avoid system properties polluting other tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you elaborate how this happens

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I needed it at one point, but I agree it doesn't seem like it should be needed, and passed when I just ran locally without it

@trask trask merged commit 44fe94e into open-telemetry:main Oct 26, 2025
81 checks passed
@trask trask deleted the kafka-config branch October 26, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor existing kafka-clients interceptors in library instrumentation

2 participants